<template>
	<div>
		<div>
			<van-nav-bar
			  title=""
			  left-text="返回"
			  left-arrow
			  @click-left="onClickLeft"
			/>
		</div>


		<van-row>
			<van-col span="2"></van-col>
			<van-col span="20">
				<div style="margin-top: 200px;">
					<van-uploader :after-read="afterRead">
						<van-image round width="10rem" height="10rem" :src="headurl" />
					</van-uploader>
				</div>
				<div style="margin-top: 30px;">
          <van-button @click="tzLogin" round block type="primary">请登录</van-button>
        </div>
        <div style="margin-top: 30px;">
          <van-button @click="loginout" round block type="primary">注销</van-button>
        </div>
			</van-col>
			<van-col span="2"></van-col>
		</van-row>
	</div>
</template>

<script>
	export default {
		setup() {
		    const onClickLeft = () => history.back();
		    return {
		      onClickLeft,
		    };
		  },
		data() {
			return {
				headurl: "https://img.yzcdn.cn/vant/cat.jpeg"
			}
		},


		methods: {
			tzLogin() {
				this.$router.push("/login");
			},
			afterRead(file) {
				var that = this;
				console.log(file);
				const forms = new FormData();
				forms.append("file", file.file);
				this.axios.post("oss/uploadHeadImg" ,forms, {
				headers: {
					'Conent-Type': 'multipart/form-data',
				},
		}).then((res) => {
					if (res.data.code == 200) {
						that.headurl = res.data.data;
					}
				}).catch((e) => {

				})
			},
      loginout(){
        this.axios.get("/api/user/loginout.do").then((res)=>{
          token:this.$store.state.token;



          if(res.data.code==200){
            this.$toast.success('退出成功');
            this.$router.push("/login");
          }else{
            this.$toast.fail('网络异常');
          }
        });

      },
		}
	}
</script>

<style>

</style>
